<%@page import="java.sql.*" %>
<% String id = request.getParameter("stuid");%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>条件查询</title>
    <%! ResultSet rs; //数据库查询结果集%>
    <%
        String dbName = "school";//数据库
        String userName ="root";//账户
        String userPassword ="qwert";//密码
        String url ="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPassword;
        Class.forName("com.mysql.cj.jdbc.Driver");//5.7以下不加.cj
        Connection conn = DriverManager.getConnection(url);//连接数据库
        Statement statement = conn.createStatement();//创建操作对象
        String sql = "select * from student where number ="+id;//查询学生表所有字段
        rs = statement.executeQuery(sql);//运行sql命令查询数据 结果放到rs结果集中
    %>
</head>
<body>
<table border="1">
    <th colspan="4" style="font-size:x-large;alignment:center">学生信息表</th>
    <tr style="text-align:center">
        <td>学号</td>
        <td>姓名</td>
        <td>出生日期</td>
        <td>所在班级</td>
    </tr>
    <% while (rs.next()){%>
    <tr style="text-align:center">
        <td><%=rs.getString(1)%></td>
        <td><%=rs.getString(2)%></td>
        <td><%=rs.getString("birthday")%></td>
        <td><%=rs.getString("stuclass")%></td>
    </tr>
    <% } %>
</table>
<%--关闭数据库连接--%>
<%
    rs.close();
    statement.close();
    conn.close();
%>
</body>
</html>